<template>
	<view class="pagecon">
		<head-box></head-box>
			<view class="page_mian">
				<view class="banner">
					<image src="/static/img/wlfx_banner.png" mode="aspectFill"></image>
				</view>
				<view class="quntuanListPage-main-header">
					<div class="quntuanListPage-main-title">我来奉献</div>
				</view>
				<view class="personalInfor-page-main">
					<view class="personalInfor-page-main-box">
						<view class="_main-item" >
							<view class="_main-item-chunk _main-item-label"><text>名称</text></view>
							<view class="_main-item-chunk _main-item-val">
								 <input cursorSpacing="10" class="_main-item-val-input" type="text" placeholder="请输入姓名或者公司名" v-model="userNickname"/>
								<image class="drop-dowm-img" src="../../static/img/drop-down.png" mode=""></image>
							</view>
						</view>
						<view class="_main-item" >
							<view class="_main-item-chunk _main-item-label"><text>手机号码</text></view>
							<view class="_main-item-chunk _main-item-val">
								 <input cursorSpacing="10" class="_main-item-val-input" maxlength="11" type="text" placeholder="手机号码" v-model="userPhone"/>
								<image class="drop-dowm-img" src="../../static/img/drop-down.png" mode=""></image>
							</view>
						</view>
						<view class="_main-item" >
							<view class="_main-item-chunk _main-item-label"><text>服务类型</text></view>
							<view class="_main-item-chunk _main-item-val">
								<picker class="_main-item-val-input" @change="changetype" :value="TypeIndex" :range="TypeArr" >
									<view class="uni-input _main-item-val-input-text">
										{{TypeArr[TypeIndex]}}
										<image class="drop-dowm-img" src="../../static/img/drop-down.png" mode=""></image>
									</view>
								</picker>
							</view>
						</view>
					</view>
				</view>
				<view>
					<textarea cursorSpacing="10" class="textarea" v-model="advice" placeholder="请输入您的提供的服务,以及时间,人数等信息"></textarea>
				</view>
				<view class="subbtn">
					<button type="primary"  @click="submit">提交我的奉献信息</button>
				</view>
			</view>
		<tabs-box></tabs-box>
	</view>
</template>

<script>
	import { mapState,mapMutations} from 'vuex';
	import { gpUseradvisesubmit,gpGpinfoList} from '@/common/request.js';
  import {goLogin} from '@/common/base'
	export default {
		data() {
			return {
				advice:'',
				userNickname:'',
				userPhone:'',
				TypeArr:["请选择","志愿者服务","捐赠服务"],
				TypeArrall:["0","1","2"],
				TypeIndex: 0,
				pageSize:20,
				pageNo:1,
			};
		},
		computed: {
			...mapState(['hasLogin', 'userInfo','token'])
		},
		onLoad() {
			if(!uni.getStorageSync("token"))
			{
        goLogin()
				//return;
			}
			//this.getList();
		},
    onShow(){
      // #ifdef H5
      console.log('分享')
      this.$wxSetShare()
      // #endif
    },
		methods: {
			submit()
			{


				if(this.chooseTypeIndex ==0)
				{
					this.$api.msg('请选择目标群团');
					return;
				}
				if(this.TypeIndex == 0)
				{
					this.$api.msg('请选择类型');
					return;
				}
				if(this.advice =='')
				{
					this.$api.msg('请输入您要对我们说的话');
					return;
				}

				if(!uni.getStorageSync("token"))
				{
					this.$api.msg('请先登录!!');
					return;
				}
				var params ={"adviseContent": this.advice,"useradviseType":this.TypeArrall[this.TypeIndex],"gpinfoId":this.chooseTypeArrall[this.chooseTypeIndex]}
				console.log(params);
				gpUseradvisesubmit(params).then(res => {
					console.log(res)

					if(res.success)
					{
						this.$api.msg('提交成功,感谢您的建议');
						this.advice = '';
						setTimeout(() => {
							uni.navigateTo({
								url:'/pages/mySuggestion/mySuggestion'
							})
						}, 1000);
					}
				});
			},
			changetype(e) {
				console.log('picker发送选择改变，携带值为', e.target.value)
				this.TypeIndex = e.target.value
				console.log(this.TypeArrall[this.TypeIndex]);
				//this.GetList()
			},

		}
	}
</script>

<style lang="scss">
	.pagecon{
		height: 100vh;
		.page_mian{
			padding: 30rpx;
			.banner{
				width: 100%;
				height: 280rpx;
				margin-bottom: 60rpx;
				image{
					width: 100%;
					height: 100%;
					border-radius: 10rpx;
				}
			}

			.quntuanListPage-main-title{
				font-size: 32rpx;
				color: #333;
				font-weight: 600;
				border-left: 6rpx solid #0071fc;
				background-image:linear-gradient(left, #eff6ff, #ffffff);
				padding-left: 20rpx;
			}

			.textarea{
				border-radius: 10rpx;
				border: 1px solid #cccccc;
				padding: 20rpx;
				width: 100%;
				margin-top: 50rpx;
			}
			.subbtn{
				margin-top: 50rpx;
			}
		}

		.personalInfor-page-main{
			width: 100%;
			box-sizing: border-box;
			margin-top: 40rpx;
			.personalInfor-page-main-box{
				width: 100%;
				._main-item{
					// height: 86rpx;
					border-bottom: 1px solid rgba(200,199,204,0.5);
					display: flex;
					flex-wrap: nowrap;
					justify-content: space-between;
					align-items: center;
					._main-item-chunk{
						font-size: 34rpx;
						color: #000;
						line-height: 84rpx;
					}
					._main-item-label{
						width: 30%;
					}
					._main-item-val{
						width: 70%;
						display: flex;
						flex-wrap: nowrap;
						justify-content: flex-end;
						align-items: center;
						._main-item-val-head{
							width: 48rpx;
							height: 48rpx;
							border-radius: 50%;
							display: flex;
							.head-img{
								width: 100%;
								height: 100%;
								border-radius: 50%;
							}
						}
						._main-item-val-input{
							text-align: right;
							display: flex;
							._main-item-val-input-text{
								display: flex;
								flex-wrap: nowrap;
								align-items: center;
							}
							.drop-dowm-img{
								width: 30rpx;
								height: 30rpx;
								margin-left: 10rpx;
								transform: rotateZ(270deg);
							}
						}
						.drop-dowm-img{
							width: 30rpx;
							height: 30rpx;
							margin-left: 10rpx;
							transform: rotateZ(270deg);
						}
					}
				}

			}
		}
	}
</style>
